﻿/*
 * 由SharpDevelop创建。
 * 用户： Administrator
 * 日期: 2014/3/15
 * 时间: 22:53
 * 
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
using System;

namespace Step
{
	public class Stack
	{
		Entry top;

		public void Push(object data) {
			top = new Entry(top, data);
		}

		public object Pop() {
			if (top == null) throw new InvalidOperationException();
			object result = top.data;
			top = top.next;
			return result;
		}

		class Entry
		{
			public Entry next;
			public object data;

			public Entry(Entry next, object data) {
				this.next = next;
				this.data = data;
			}
		}
	}
}